Background
The stack simulates any kind
of line situation in which there is a single point for entry and exit. Think of a discard deck of cards or other
similar kind of “pile”.
Detail
You will implement 3 stack
classes which will contain a Stack of Card objects. Here are the Card and Deck classes you will need. Each of these classes will have the following methods (based on
the Stack ADT “rules”):
1. A constructor that sets-up this particular stack
implementation.
2.
A push method
which adds an object to the stack. Returns
a true or false depending on the success of the push operation. (Technically, unless
the stack has a limited amount of space available, this will always return
true.)
3. A pop method that removes the top object from
the stack and returns the object to the calling method.
4. A peek method which returns a copy of the top
object in the stack.
5. An isEmpty method that returns true if the
queue is empty.
Your three classes will be all called Stack. You should make three different directories, one for each type of Stack.
The three implementations
will include:
Array – an array
implementation of a Stack. You may
either make an unlimited stack which will copy an array from one array to
another if you need to push an element on and there is no room or you may
simply return false if your Stack does not have room for the new element.
ArrayList – an arrayList
implementation of a Stack.
LinkedList – a linked list
implementation of a Stack.
Part 1 (Due Tuesday April 26, 2005):
Submission
Submit part 1 by turning your code into the Blackboard Assignments for this lab. Since we are dealing with 3 programs with the same name, there will be three assignments, one for the Driver and the Array Stack, one for the ArrayList Stack and one for the LinkedList Stack. Your stubs must be working stubs; in other words the programs should compile and run, although you will only have constant return values.
Part 2 (Due Thursday April 28, 2005):
Submission
Submit all three Stack classes to the Blackboard assignment as before. You do not need to submit your driver. Print the code for each of your classes and turn that in at the beginning of lecture on Thursday.